|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.sun.j3d.loaders.LoaderBase
|
+--com.mnstarfire.loaders3d.Loader3DS
3DS File Analyzer / Loader
Copyright (c) 2000,2001, 2003 Starfire Research - All Rights Reserved.
Last Modified: February 11, 2003
Usage:
// setup a file name "fileName"
try {
Loader3DS loader = new Loader3DS();
// optional options to be used
// loader.setLogging(true); // turns on writing a log file
// loader.setDetail(7); // sets level of detail of report log
// loader.setTextureLightingOn(); // turns on texture modulate mode
// loader.setTexturePath("D:\MyTextures"); // optional alternate path to find texture files
// loader.noTextures(); // turns off loading of textures
Scene theScene = loader.load(fileName);
}
catch(FileNotFoundException fnf) {
// Couldn't find the file you requested - deal with it!
}
// Use the scene as per Sun's documentation of SceneBase
Usage via URL:
// setup a URL "url"
// setup a String "urlBase" (where to find the textures)
try {
Loader3DS loader = new Loader3DS();
// optional options to be used
// loader.setTextureLightingOn(); // turns on texture modulate mode
loader.setURLBase(urlBase); // critical for loading textures
Scene theScene = loader.load(url);
}
catch(FileNotFoundException fnf) {
// Couldn't find the file you requested - deal with it!
}
// Use the scene as per Sun's documentation of SceneBase
Notes:
Picking capabilities are set for INTERSECT_COORD
Smoothing could be ignored to improve performance.
Java shininess is 1.0 to 128.0 (clamped), but 3DS is 0.0 to 1.0.
I'm mapping 3DS shininess (Max "Glossiness") to 0.0 to 128.0 (slightly wrong on low end)
Max "Specular Level" is 3DS "Shininess Strength" (SHIN2PCT)
Named Grouping is now supported.
On virtually all Materials we skip:
a041 - MAT_SHIN2PCT - shininess strength (a percentage)
a052 - MAT_XPFALL - transparency fall off ratio (center to edge)
a053 - MAT_REFBLUR - reflection blurring
a084 -
a08a -
a087 - MAT_WIRESIZE - rendered wiresize
a100 - MAT_SHADING - which shading method to use (assume only Gouraud)
a230 - MAT_BUMPMAP
Also ignored:
7001 - Viewport layout
1400 thru 1460 - Shadow info
1100 - Background Bitmap
1200 - Background Color
1300 - Gradient Background
2200 - Fog
2300 - DISTANCE_CUE - darkening used with fog?
2302 - Layer Fog
30xx - Viewport Chunks
How we are handling two sided materials:
m2table - hash table matching material hash table containing info about the material
ie is it 2 sided or not
Using m2table to know if it is 2 sided we then generate duplicate triangles for the
geometry with the order of the vertices reversed. This will result in a Shape3D with
double the number of vertices! But we should have proper normals so even the backside of
these materials is lit correctly.
Note:
Rotation of "named groups" is likely to be confusing as by default rotation is around
(0,0,0) and whomever created the model is likely to have not made every group's pivot
point at (0,0,0). Can we pick up the pivot points and adjust for this?
What I'm thinking is transform the vertex locations by the pivot point (to orient them
around (0,0,0) then put the pivot point translation into the parent TransformGroup.
Paul Byrne of Sun provided much appreciated assistance in adding features
and functionality.
| Field Summary |
| Fields inherited from class com.sun.j3d.loaders.LoaderBase |
basePath, baseUrl, loadFlags |
| Fields inherited from interface com.sun.j3d.loaders.Loader |
LOAD_ALL, LOAD_BACKGROUND_NODES, LOAD_BEHAVIOR_NODES, LOAD_FOG_NODES, LOAD_LIGHT_NODES, LOAD_SOUND_NODES, LOAD_VIEW_GROUPS |
| Constructor Summary | |
Loader3DS()
|
|
Loader3DS(int flags)
No flags are available at this time |
|
| Method Summary | |
com.sun.j3d.loaders.Scene |
load(java.io.Reader reader)
Loading from a Reader is not supported at this time |
com.sun.j3d.loaders.Scene |
load(java.lang.String fileName)
Load the 3ds file specified Use scene.getSceneGroup() to get the scene graph. For optimal performance .compile() should be called on the scene group. |
com.sun.j3d.loaders.Scene |
load(java.net.URL inURL)
Loading from a URL Before calling load(url); setURLBase() MUST be called (to find textures) |
void |
noTextures()
call this if you wish to skip loading textures. |
void |
setCreaseAngle(double ca)
Use this to adjust how "rounded" objects are Values are in radians from 0 to PI - default is 0.7679 |
void |
setDetail(int desiredDetail)
This controls the level of detail reported 0 = nothing 1-8 play around with this until you reach the level you desire 9 = everything |
void |
setLogging(boolean logging)
If true is passed then as the 3DS file is parsed a log file "log3ds.txt" will be created. |
void |
setTextureLightingOn()
This turns on Texture blending (so that textures get lighting effects) |
void |
setTexturePath(java.lang.String tdpath)
This allows you to set a different directory to load textures from. If this is not set all textures are assumed to be in the same directory as the 3DS model This is ignored if loading from a URL. |
void |
setURLBase(java.lang.String base)
MUST be set when loading from a URL in order for texture files to be found |
| Methods inherited from class com.sun.j3d.loaders.LoaderBase |
getBasePath, getBaseUrl, getFlags, setBasePath, setBaseUrl, setFlags |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Loader3DS()
public Loader3DS(int flags)
| Method Detail |
public com.sun.j3d.loaders.Scene load(java.io.Reader reader)
throws java.io.FileNotFoundException
java.io.FileNotFoundException
public com.sun.j3d.loaders.Scene load(java.lang.String fileName)
throws java.io.FileNotFoundException
java.io.FileNotFoundException
public com.sun.j3d.loaders.Scene load(java.net.URL inURL)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic void setURLBase(java.lang.String base)
public void setLogging(boolean logging)
public void setDetail(int desiredDetail)
public void setTextureLightingOn()
public void setTexturePath(java.lang.String tdpath)
public void noTextures()
public void setCreaseAngle(double ca)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||